
import sys
sys.path.extend(["F:/ML/BNC", "D:/BNC", "/www/wwwroot/BNC"])
import time
from TuShare.TUShareObject import TUShareObject

import tushare as ts


def getDfDate():
    pro = TUShareObject.tushare_apiobject()
    df = pro.query('trade_cal', exchange='DCE', start_date='20180101', end_date='20181231')
    # df = pro.trade_cal(exchange='', start_date='20181022', end_date=time.strftime('%Y%m%d',time.localtime(time.time())),
    #                    fields='exchange,cal_date,is_open', is_open='1')
    # df = pro.trade_cal(exchange='', start_date='20180901', end_date='20181001',
    #                    fields='exchange,cal_date,is_open,pretrade_date', is_open='0')
    # print(type(df))
    return df
def getAllCode():
    pro = TUShareObject.tushare_apiobject()
    data = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
    codes = list()

    for index, row in data.iterrows():
        codes.append(row['ts_code'])
    return codes
if __name__ == "__main__":
    # df = getDfDate()
    # print(df)
    # for index, row in df.iterrows():
    #     print("交易日期:%s 开盘状态:%s" %(row["cal_date"], row["is_open"]))
    # print(type(df))
    print(len(getAllCode()))